<?php

declare(strict_types=1);

namespace App\CustHub\Controller;

use App\CustHub\Annotation\ApiAuth;
use App\CustHub\Annotation\ChOperationLog;
use App\CustHub\Annotation\ChPermission;
use App\CustHub\Annotation\VerifySignature;
use App\CustHub\Request\RoomKeywordRequest;
use App\CustHub\Request\RoomKickUserRequest;
use App\CustHub\Service\ChRoomKickUserService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\PostMapping;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Http\Message\ResponseInterface;

/**
 * 直接踢人
 */
#[Controller('ch/room/kickuser'),ApiAuth,VerifySignature]
class RoomKickUserController extends BaseController
{
    #[Inject]
    protected ChRoomKickUserService $service;

    /**
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    #[PostMapping('list'),ChPermission('ch:room:kickuser, ch:room:kickuser:list')]
    public function list(): ResponseInterface
    {
        return $this->success($this->service->list($this->request->all()));
    }

    /**
     * 新增
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    #[PostMapping('save'),ChOperationLog]
    public function save(RoomKickUserRequest $request): ResponseInterface
    {
        return $this->success(['id'=>$this->service->save($request->all())]);
    }

    /**
     * 编辑
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    #[PostMapping('update'),ChOperationLog]
    public function update(RoomKickUserRequest $request): ResponseInterface
    {
        return $this->service->update($request->input('id'),$request->all()) ? $this->success() : $this->error();
    }

    /**
     * 重命名
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    #[PostMapping('rename'),ChOperationLog]
    public function rename(RoomKickUserRequest $request): ResponseInterface
    {
        return $this->service->rename($request->input('id'),$request->all()) ? $this->success() : $this->error();
    }

    /**
     * 删除
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    #[PostMapping('delete'),ChOperationLog]
    public function delete(RoomKeywordRequest $request): ResponseInterface
    {
        return $this->service->deleteScheme($request->input('id')) ? $this->success() : $this->error();
    }
}